package com.gaoyubo.controller;

import com.gaoyubo.entity.Goods;
import com.gaoyubo.service.GoodsService;
import com.gaoyubo.vo.GoodsVo;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
public class GoodsController {
    @Autowired
    private GoodsService goodsService;
    @RequestMapping("list")
    public PageInfo<Goods> getList(
            @RequestParam(defaultValue = "1")Integer pageNum,
            @RequestParam(defaultValue = "3")Integer pageSize,
            GoodsVo goodsVo){
        System.out.println("pageNum:"+pageNum);
        System.out.println("pageSize:"+pageSize);
        return goodsService.getList(pageNum,pageSize,goodsVo);
    }
    @RequestMapping("getListById")
    public Object getListById(Integer id){
        return goodsService.getListById(id);
    }
    @RequestMapping("saveOrUpdate")
    public boolean saveOrUpdate(@RequestBody Goods goods){
        boolean a =false;
        a= goodsService.saveOrUpdate(goods);
        return a;
    }
    @RequestMapping("getUpById")
    public Goods getUpById(Integer id){
        System.out.println("getUpById");
        return goodsService.getUpById(id);
    }
    @RequestMapping("delete")
    public boolean delete(Integer id){
        return goodsService.delete(id);
    }
}
